/**
 * 最近更新: 2018-10-27
 * 作者: xuek
 * 功能: cookie操作
 */

export const oCookie = {
	add:function(name,value,lifeCircle){
        let oDate = new Date();
        oDate.setTime(oDate.getTime() + (lifeCircle * 24 * 60 * 60 * 1000));
		document.cookie = name + '=' + value + ';expires=' + oDate.toGMTString() + ";path=/";
	},
	del:function(name){
		let oDate = new Date();
		oDate.setDate(new Date().getDate() - 1);
		this.add(name,1,-1);
	},
	get:function(name){
		let arr = document.cookie.split('; ');
		for(let i=0;i<arr.length;i++){
			let keyValArr = arr[i].split("=");
			if(keyValArr[0] == name) {
				return keyValArr[1];
			}
		}
		return '';
	}
}